﻿using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Windows;

using ContestMeter.Common;
using ContestMeter.Teacher.UI.Properties;
using Microsoft.Practices.Unity;

namespace ContestMeter.Teacher.UI
{
    /// <summary>
    /// Interaction logic for App.xaml
    /// </summary>
    public partial class App : Application
    {
        public IUnityContainer RootContainer { get; private set; }

        protected override void OnStartup(StartupEventArgs e)
        {
            RootContainer = new UnityContainer();
            var fs = new LocalFileSystem();
            var config = Configuration.Load(fs, Settings.Default.TestsFolder, "");

            RootContainer.RegisterInstance<IConfiguration>(config,
                new ContainerControlledLifetimeManager());
            RootContainer.RegisterInstance<IFileSystem>(fs, 
                new ContainerControlledLifetimeManager());

            MainWindow = RootContainer.Resolve<MainViewModel>().View;
            MainWindow.Show();
            base.OnStartup(e);
        }
    }
}
